package com.lagou.module4_6;

/**
 * @author wsl
 * @date 2021/8/1 16:18
 * @project_name javase
 */
public class Employee {
    private String name;  //姓名
    private int age;      //年龄

    public Employee() {
    }

    public Employee(String name, int age) {

        if (age<18 || age>150){
            try {
                throw new AgeException("年龄不合法！");
            } catch (AgeException e) {
                e.printStackTrace();
            }
        } else {
            this.name = name;
            this.age = age;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
            this.name = name;

    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
            this.age = age;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
